package com.qire.manhua.model.vo;

import com.qire.common.basic.StringUtil;
import com.qire.common.support.base.BaseVO;
import com.qire.manhua.model.entity.MarketInfo;

import java.util.ArrayList;

/**
 * Created by Administrator on 2018/6/9.
 * <pre>
 *  市场销售信息：
 *      产品信息：Wares
 *      新人福利：welfare
 * </pre>
 */
public class MarketInfoVO extends BaseVO {

    public int is_first;                            //是否首充：0-否，1-是
    public ArrayList<WaresVO> wares;                  //商品列表：List<Wares>
    public NewcomerWelfareVO welfare;               //新人充值福利，
    public String qq;                               //: "613276228"

    public class WaresVO {

        public int fee;                             //充值金额 : 50,
        public int bean;                            //积分豆 : 10
    }

    public MarketInfo toMarketInfo() {
        MarketInfo marketInfo = new MarketInfo(is_first==1);
        for(WaresVO ware : wares) {
            int fee         = ware.fee;
            int goldCoin    = ware.fee * 100;
            int rewardFee   = ware.bean;
            int rewardBean  = ware.bean * 100;
            marketInfo.waresEntityList.add(marketInfo.new WaresEntity(fee, goldCoin, rewardFee, rewardBean));
        }

        if(welfare!=null && StringUtil.valueToInt(welfare.is_open,0) == 1 && welfare.ttl > 0) {
            int fee         = StringUtil.valueToInt(welfare.price,0);
            int goldCoin    = StringUtil.valueToInt(welfare.coin,0);
            int rewardFee   = StringUtil.valueToInt(welfare.bean,0)/100;
            int rewardBean  = StringUtil.valueToInt(welfare.bean,0);
            marketInfo.setNewcomerWares(marketInfo.new WaresEntity(fee, goldCoin, rewardFee, rewardBean));
            marketInfo.setFailureCountdown(welfare.ttl);
        }

        return marketInfo;
    }

}
